﻿using Imgur.Net.Util;
using NUnit.Framework;

namespace Imgur.Net.Test.Util
{
    [TestFixture]
    public class ObservableHelperTests
    {
        public class TestType
        {
            public int SomeBoxedProperty { get; set; }
            public object SomeReferenceTypeProperty { get; set; }
        }

        [Test]
        public void GetPropertyNameForBoxedPropertyTest()
        {
            string propName = ObservableHelper.GetPropertyName<TestType>(
                x => x.SomeBoxedProperty);

            Assert.AreEqual("SomeBoxedProperty", propName);
        }

        [Test]
        public void GetPropertyNameForNonBoxedPropertyTest()
        {
            string propName = ObservableHelper.GetPropertyName<TestType>(
                x => x.SomeReferenceTypeProperty);

            Assert.AreEqual("SomeReferenceTypeProperty", propName);
        }

        [Test]
        public void GetPropertyChangeArgsCreateTest()
        {
            var args = ObservableHelper.CreateArgs<TestType>(x => x.SomeReferenceTypeProperty);

            Assert.IsNotNull(args);
            Assert.AreEqual("SomeReferenceTypeProperty", args.PropertyName);
        }
    }
}
